home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmigaPlus / Begleitmaterial / 50Tools / Grafik / PerfectPaint / rexx / general / SavePng_Brush2.rx < prev    next >
Text File  |  2003-06-26  |  3KB  |  178 lines

  1. /*  arexx Script 
  2.   SAVE Picture in PNG format
  3.   need 'PNGtool' in PerfectPaint:tools/  
  4. */
  5.  
  6.   options results
  7.   parse ARG Port b
  8.   ADDRESS value Port
  9.   pp_AvoidRefresh
  10.  
  11.   file=""
  12.   file2=""
  13.   option=0
  14.     compression=5
  15.     interlace=0
  16.     version=0
  17.  
  18.   if EXISTS('PerfectPaint:Prefs/Rexx_Prefs/SavePng_Brush2') THEN DO
  19.     IF OPEN('lfile','PerfectPaint:Prefs/Rexx_Prefs/SavePng_Brush2', "R") then DO
  20.       file = READLN('lfile')
  21.       option=READLN('lfile')
  22.             compression=READLN('lfile')
  23.             interlace=READLN('lfile')
  24.             version=READLN('lfile')
  25.       CALL CLOSE('lfile')
  26.       file2=""
  27.       do i=1 to LENGTH(file)
  28.         a=SUBSTR(file,i,1)
  29.         if a=" " then DO
  30.           a="*"
  31.         END
  32.         file2=file2||a
  33.       END
  34.       file=file2
  35.     END
  36.   END
  37.  
  38.   pp_showscreen
  39.  
  40.     pp_GetDepth
  41.     D=result
  42.  
  43.     IF D<24 then DO
  44.       pp_DialogInit 250 160 "*Save*Png*Brush*" 6
  45.     END
  46.     ELSE DO
  47.       pp_DialogInit 250 195 "*Save*Png*Brush*" 9
  48.     END
  49.  
  50.     pp_String 0 50 12 150 16 "Name" 1 100 file
  51.  
  52.     n=LASTPOS('/',file)
  53.     if n=0 then DO
  54.       n=LASTPOS(':',file)
  55.       file=SUBSTR(file,1,n)
  56.     END
  57.     else DO     
  58.       file=SUBSTR(file,1,n)
  59.     END
  60.  
  61.     pp_Getfile 1 205 13 0 "Save*Png" 0 file
  62.  
  63.         IF D<24 then DO
  64.         pp_Cycle 2 100 32 100 16 "Transparency" 1 "No|Yes" option            
  65.         END
  66.         ELSE DO
  67.         pp_Cycle 2 95 32 130 16 "Transparency" 1 "No|Use*Current*Mask" option
  68.         END
  69.  
  70.       pp_Slider 3 100 52 100 16 "Compression" 1 0 9 compression
  71.  
  72.       pp_Cycle 4 100 72 100 16 "Interlaced" 1 "No|Yes" interlace
  73.  
  74.       pp_Cycle 5 100 102 110 16 "Version" 1 "68000|PPC*(WarpUp)" version            
  75.  
  76.         IF D>8 then DO
  77.         pp_Text 6 10 145 "'PBM.datatype'*must*be*installed,"
  78.         pp_text 7 10 155 "if*you*want*to*save*your*PNG*Brush*with"
  79.         pp_text 8 10 165 "Transparency."
  80.         END
  81.         
  82.         pp_Dialog 
  83.  
  84.   rc=result
  85.   if rc=0 then
  86.     do
  87.       pp_PermitRefresh
  88.       EXIT
  89.     end 
  90.  
  91.   pp_GetDialog 0
  92.   file=result
  93.  
  94.   pp_GetDialog 2
  95.   option=result
  96.  
  97.   pp_GetDialog 3
  98.   compression=result
  99.  
  100.   pp_GetDialog 4
  101.   interlace=result
  102.  
  103.   pp_GetDialog 5
  104.   version=result
  105.  
  106.   CALL SavePrefs('SavePng_Brush2',file,option,compression,interlace,version)
  107.   ADDRESS value Port
  108.  
  109.     pp_SavePrefs 0 1 100 0 0
  110.     AA0="T:pp_Picture.iff"
  111.     pp_bSave AA0 0 1
  112.  
  113.   IF option=0 then DO
  114.         AA=" T=-1 "
  115.     END
  116.   ELSE DO
  117.         IF D=24 then DO
  118.             AA1="T:pp_Stencil.stn"
  119.             pp_InvBrushStencil
  120.             pp_bmSave AA1
  121.             pp_InvBrushStencil
  122.             AA=" A="||AA1||" "
  123.         END
  124.         ELSE DO
  125.             AA=" T=0 "
  126.         END
  127.     END
  128.  
  129.     AI=""
  130.     IF interlace=1 then DO
  131.         AI=" Interlaced "
  132.     END
  133.  
  134.     AC=" C="||compression
  135.  
  136.   pp_asay 'Making*PNG*file|Please*wait*...'     
  137.  
  138.      address COMMAND    
  139.     if version=0 then do
  140.         'perfectpaint:tools/PNGtool '||AA0||' '||file||' '||AA||AI||AC
  141.     end
  142.     else do
  143.         'perfectpaint:tools/PNGtoolPPC '||AA0||' '||file||' '||AA||AI||AC
  144.     end
  145.  
  146.   'delete >nil: '||AA0
  147.   'delete >nil: '||AA1        
  148.  
  149.   ADDRESS value Port
  150.     pp_SaveIconFor file 0
  151.   pp_closeasay
  152.  
  153.   pp_PermitRefresh
  154.   EXIT    
  155.  
  156.  
  157.  
  158. SavePrefs: PROCEDURE
  159.   
  160.   Prefname='PerfectPaint:Prefs/Rexx_Prefs/'||ARG(1)
  161.  
  162.   if EXISTS(Prefname) THEN DO
  163.     ADDRESS COMMAND
  164.     'delete >nil: '||Prefname
  165.   END
  166.  
  167.   IF OPEN('pfile',PrefName,'W') THEN DO
  168.  
  169.   do i=2 to ARG()
  170.     CALL WRITELN('pfile',ARG(i))
  171.   end
  172.  
  173.   CALL CLOSE('pfile')
  174.  
  175. RETURN  
  176.  
  177.  
  178.